package com.gzmu.face.serviceImpl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.gzmu.face.entity.Verifypush;
import com.gzmu.face.mapper.VerifypushMapper;
import com.gzmu.face.service.VerifypushService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xiaobo Yan
 * @since 2020-04-19
 */
@Service
public class VerifypushServiceImpl extends ServiceImpl<VerifypushMapper, Verifypush> implements VerifypushService {
    @Autowired
    private VerifypushMapper verifypushMapper;

    @Transactional
    @Override
    public Map getLastVerifyPush() {
        Map<String, Object> map = new HashMap<>();
        Verifypush verifyPush = verifypushMapper.LoadData();
        if(verifyPush==null){
            map.put("code",201);
        }else {
            verifypushMapper.UpdateData();
            map.put("name",verifyPush.getName());
            map.put("temp", verifyPush.getTemperature() );
            map.put("snappic", verifyPush.getSanpPic() );
            map.put("code",200);
        }
        map.put("total", verifypushMapper.LoadDayTotal() );
        map.put("alarm", verifypushMapper.LoadAlarmTotal() );
        return map;
    }
}
